package com.sgz.test.bean.proxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * Created with IntelliJ IDEA.
 * User: sunguangzhu
 * Date: 13-8-12
 * Time: 下午2:30
 * To change this template use File | Settings | File Templates.
 */
public class HelloWorldHandler implements InvocationHandler {
    //目标对象
    private Object targetObject;

    public HelloWorldHandler(Object targetObject){
        this.targetObject = targetObject;
    }

    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("方法调用前。。。");

        Object result = method.invoke(this.targetObject, args);

        System.out.println("方法调用结束");

        return result;
    }
}

